﻿using WPay.Application.Interface.OAuth;
using WPay.Domain.Model.DTOs;
using WPay.Domain.MainModule.Interface.DomainServices;
using System.Collections;

namespace WPay.Application.MainModule.OAuth
{
    public class Token_ApplicationService : IToken_ApplicationService
    {
        /// <summary>
        /// 领域服务接口
        /// </summary>
        IToken_DomainService token_DomainService;
        /// <summary>
        /// API交互输出数据包
        /// </summary>
        private Hashtable datas;

        public Token_ApplicationService(IToken_DomainService _token_DomainService)
        {
            token_DomainService = _token_DomainService;
        }
        public RespDto GetToken(string _appId, string _appSecret)
        {
            TokenDTO tokenDto = new TokenDTO() { AppId = _appId, AppSecret = _appSecret };
            bool isSuccess = token_DomainService.GetToken(ref tokenDto);
            datas = new Hashtable();
            datas.Add("Data", tokenDto);
            return new RespDto(isSuccess, isSuccess ? 0 : 200, isSuccess ? "获取授权成功" : "获取授权失败", datas);
        }
        public bool CheckToken(string _token, out string _appID)
        {
            return token_DomainService.CheckToken(_token, out _appID);
        }

    }
}
